*------------------------------------------------------------------------------
* Entwicklung der Neigung auf beiden Ebenen dieselbe Partei zu wählen
*------------------------------------------------------------------------------



putexcel set "tables\aggregate_votesplit.xlsx", sheet(vote) replace

putexcel A2 = "W14"
putexcel A3 = "W15"
putexcel A4 = "W16"
putexcel A5 = "W17"
putexcel A6 = "W18"


//Columns
putexcel B1 = "CDU"
putexcel C1 = "SPD"
putexcel D1 = "FDP"
putexcel E1 = "Grüne"
putexcel F1 = "Linke"
putexcel G1 = "AfD"



//Formatting
putexcel A1:A6, right border(right) overwritefmt
putexcel A1:G1, hcenter bold border(bottom) overwritefmt



local zeile 1

		foreach wave of numlist $all {
		local zeile = `zeile'+1
		
		fre same_hyp`wave'	if NIwahl`wave' == 1
		mat same_hyp_mat = r(valid)
		putexcel B`zeile' = (same_hyp_mat[2,1])
		putexcel H`zeile' = `r(N_valid)' //Valid cased
		fre same_hyp`wave'	if NIwahl`wave' == 4
		mat same_hyp_mat = r(valid)
		putexcel C`zeile' = (same_hyp_mat[2,1])
		putexcel I`zeile' = `r(N_valid)' //Valid cased
		fre same_hyp`wave'	if NIwahl`wave' == 5	
		mat same_hyp_mat = r(valid)
		putexcel D`zeile' = (same_hyp_mat[2,1])
		putexcel J`zeile' = `r(N_valid)' //Valid cased
		fre same_hyp`wave'	if NIwahl`wave' == 6	
		mat same_hyp_mat = r(valid)
		putexcel E`zeile' = (same_hyp_mat[2,1])
		putexcel K`zeile' = `r(N_valid)' //Valid cased
		fre same_hyp`wave'	if NIwahl`wave' == 7	
		mat same_hyp_mat = r(valid)
		putexcel F`zeile' = (same_hyp_mat[2,1])
		putexcel L`zeile' = `r(N_valid)' //Valid cased
		fre same_hyp`wave'	if NIwahl`wave' == 322	
		mat same_hyp_mat = r(valid)
		putexcel G`zeile' = (same_hyp_mat[2,1])
		putexcel M`zeile' = `r(N_valid)' //Valid cased

	}
